<?php
	$css_list[0]['url'] = './tpl/css/setting.css';
	$js_list[0] = './public/js/city.js';
?>
<!--{template inc/header}-->
<div id="body" class="fm960">
	<div class="piece1">
		<div class="piece1_bd clearfix">
			<div id="content" style="width:960px;">
				<!--{template inc/settings/settings_menu}-->
				<div id="setting_box" class="fl">
					<div id="setting_form" class="setting_basic">
						<form id="avartarForm" method="POST" action="{u settings/savecustom}">
							<input type="hidden" name="action" value="custom" />
							<dl>
								<dd>自定义封面：</dd>
								<dt><a href="{u u/me}" class="img"><img class="head_bd r3" width="300" height="109" src="{custom $_FANWE['user']['custom'] s}" alt="点击预览自定义封面"><span>点击预览自定义封面</span></a></dt>
								<dd>上传新封面：</dd>
								<dt style="position:relative;">
									<!--{if FS('Image')->getIsServer()}-->
									<div id="UPLOAD_AVATAR_FLASH_BOX"></div>
									<input name="custom_info" id="customInfo" type="hidden" value="" />
									<!--{else}-->
									<input type="hidden" id="viewCustom" name="user_custom" />
									<input type="file" class="tfile" id="uploadCustom" name="custom" onchange="UploadCustom();" style="border:solid 1px #999; font-size:16px; padding:3px;" value="点击上传封面"/>
									<!--{/if}-->
								</dt>
								<dd class="msg">&nbsp;</dd>
								<dt class="msg" id="custommsg">
请尽可能选择大图片，太小的图片可能会显得模糊。最佳尺寸960x330。</dt>
								<dd class="preview hide">预览：</dd>
								<dt class="preview hide">
									<img class="head_bd round" width="300"/>
								</dt>
								<dd class="avartar_confirm hide">&nbsp;</dd>
								<dt class="avartar_confirm hide">
									<input type="hidden" name="action" value="savecustom" />
									<input type="submit" value="确定" class="green_button"/>
								</dt>
							</dl>
						</form>
					</div>
				</div>
			</div>
		</div>
		
	</div>
</div>
<script type="text/javascript">
<!--{if !FS('Image')->getIsServer()}-->
var isUpload = false;
function UploadCustom()
{
	if(isUpload)
		return;
	else
		isUpload = true;
	
	$("#custommsg").html("正在上传，请稍后……");
	$.ajaxFileUpload({
		url:SITE_PATH + "services/service.php?m=user&a=custom",
		secureuri:false,
		fileElementId:'uploadCustom',
		dataType:'json',
		success:function(result)
		{
			if(result.src != '')
			{
				$("#viewCustom").val(result.src);
				$(".preview").show();
				$(".avartar_confirm").show();
				$(".preview img").attr("src",SITE_PATH + result.src);
				$(".msg").hide();
			}
			else
			{
				$(".preview").hide();
				$(".avartar_confirm").hide();
				$(".msg").show();
				$("#custommsg").html("上传失败");
			}
			
			isUpload = false;
		},
		error:function (data, status, e)
		{
			$(".preview").hide();
			$(".avartar_confirm").hide();
			isUpload = false;
			$("#custommsg").html("上传失败");
		}
	});
}
<!--{else}-->
jQuery(function($){
	var flashvars = {
		siteUrl:SITE_URL,
		btnUrl:TPL_PATH + "images/uploadpic.png",
		imageServer:'',
		type:"uploadcustom"
	};

	var params = {
		wmode: "transparent",
		allowScriptAccess: "always"
	};
	var data = new Date();
	swfobject.embedSWF(PUBLIC_PATH + "swf/upload.swf?" + data.toGMTString(), "UPLOAD_AVATAR_FLASH_BOX", "181", "28", "9.0.0", null, flashvars, params);
});

function UploadCustomLoading()
{
	$("#custommsg").html("正在上传，请稍后……");
	$(".preview").hide();
	$(".avartar_confirm").hide();
	$(".msg").show();
}

function UploadCustomComplete(status,img,info)
{
	if(status == 1 && img != '')
	{
		$("#customInfo").val(info);
		$(".preview").show();
		$(".avartar_confirm").show();
		$(".preview img").attr("src",img);
		$(".msg").hide();
	}
	else
	{
		$(".preview").hide();
		$(".avartar_confirm").hide();
		$(".msg").show();
		$("#custommsg").html("上传失败");
	}
}
<!--{/if}-->
</script>
<!--{template inc/footer}-->